home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / 3270XCMD / TNSendCmd.c < prev    next >
Text File  |  1989-08-23  |  2KB  |  97 lines

  1. /* TNSendCmd.c -- XCMD to send a command to TN3270 through the TN3270 driver 
  2.     copyright 1989 Cornell University 
  3. */
  4.  
  5.  
  6. #include <Types.h>
  7. #include <Memory.h>
  8. #include <Devices.h>
  9. #include <HyperXCmd.h>
  10. #include <Errors.h>
  11.  
  12. #include <String.h>
  13.  
  14. #include "TNdrvr.h"
  15.  
  16.  
  17. pascal void debugger()    extern 0xA9FF;   
  18.  
  19.  
  20. pascal void TNSendCmd(hycp)
  21. XCmdPtr hycp;
  22. {
  23.     CntrlParam drvpb;
  24.     long * args;
  25.     Str255 pstr;
  26.     
  27.     if (hycp->paramCount != 3) {
  28.         sethand(&hycp->returnValue, "TNSendCmd TNID,class,entry: need 3 arguments");
  29.         return;
  30.     }
  31.     
  32.     HLock((Handle) hycp->params[0]);
  33.     HLock((Handle) hycp->params[1]);
  34.     
  35.     ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
  36.     drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
  37.     drvpb.csCode = HTN_SENDCMD;
  38.     args = (long *) &drvpb.csParam[0];
  39.     *args++ = * (long *) hycp->params[1];
  40.     *args++ = * (long *) hycp->params[2];
  41.         /* pass the string *s to the drvr to pass on to TN3270 */
  42.     PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
  43.  
  44.     if (drvpb.ioResult) {
  45.         /* connect call failed */
  46.         switch (drvpb.ioResult) {
  47.             case HTNR_NOTN: {
  48.                 sethand(&hycp->returnValue, "TN is not running");
  49.                 break;
  50.             }
  51.             case HTNR_ACTIVE: {
  52.                 sethand(&hycp->returnValue, "TN not opened");
  53.                 break;
  54.             }
  55.             case HTNR_OPEN: {
  56.                 sethand(&hycp->returnValue, "TN has no connection");
  57.                 break;
  58.             }
  59.             case HTNR_CLASS: {
  60.                 sethand(&hycp->returnValue, "Invalid Command Class");
  61.                 break;
  62.             }
  63.             case HTNR_ENTRY: {
  64.                 sethand(&hycp->returnValue, "Invalid Command Entry");
  65.                 break;
  66.             }
  67.             case badUnitErr: {
  68.                 sethand(&hycp->returnValue, "TNID is incorrect");
  69.                 break;
  70.             }
  71.             default: {
  72.                 sethand(&hycp->returnValue, "Unknown error");
  73.                 break;
  74.             }
  75.         }
  76.     }
  77.     HUnlock((Handle) hycp->params[0]);
  78.     HUnlock((Handle) hycp->params[1]);
  79.  
  80. }
  81.  
  82.  
  83. sethand(thand, str)
  84. Handle * thand;
  85. char * str;
  86. {
  87.     if (*thand == NULL) {
  88.         *thand = NewHandle((Size) 0);
  89.     }
  90.     SetHandleSize(*thand, (long) (strlen(str) + 1));
  91.     strcpy(**thand, str);
  92. }
  93.  
  94.  
  95.  
  96.  
  97. #include <XCmdGlue.inc.c>